package com.iris.live.services.data.repositories;

import com.iris.live.services.data.models.顾客待裁决Model;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.sql.Timestamp;
import java.util.List;

/**
 * Created by ThinkPad on 2016/9/1.
 */
public interface 顾客待裁决Repository extends JpaRepository<顾客待裁决Model, Integer>, JpaSpecificationExecutor<顾客待裁决Model> {
    @Modifying
    @Query("update 顾客待裁决Model a set a.裁决时间 = ?1 where a.许可 = ?2 and a.顾客姓名 = ?3 and a.电话号码 = ?4 and a.销售顾问 = ?5")
    int updateReArbitrateDetailDate(Timestamp aDate, String permit, String cusName, String cusTel, String saleMan);


    @Query("select  a from 顾客待裁决Model a where  a.裁决时间 is null  AND   a.许可= ?1 ")
    List<顾客待裁决Model> findReArbitrate(String permit);

    @Query("select  a from 顾客待裁决Model a where  a.裁决时间 is null  AND   a.许可= ?1 and a.电话号码=?2 ")
    List<顾客待裁决Model> findReArbitrateBypermitAndTel(String permit, String telno);


    @Query("select  a from 顾客待裁决Model a where  a.裁决时间 is null " +
            "  and a.销售顾问=?1  " +
            "       AND   a.许可= ?2 and a.电话号码=?3  ")
    List<顾客待裁决Model> findReArbitrateBypermitAndTelAndsoleuser(String soleuser, String permit, String telno);









}
